/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    bool isPalindrome(ListNode* head) {
        ListNode* first = head;
        vector<int>cur;
        while (first!= nullptr)
        {
            cur.push_back(first->val);
            first = first->next;
        }
        for (int i = 0, j = cur.size() - 1; i <= j; i++, j--)
        {
            if (cur[i] != cur[j])
                return 0;
            else
                continue;
        }
        return 1;

    }
};